package com.hlbspringcloud.exception;

import com.hlbspringcloud.resp.Response;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author huanglibin
 * @Project idempotent
 * @Description 配置全局异常捕获器
 * @Date 2020-11-24-14-09-01
 * @Version 1.0
 */
@ControllerAdvice
public class MyControllerAdvice {
    @ResponseBody
    @ExceptionHandler(ServiceException.class)
    public Response serviceException(ServiceException exception){
        Response response = new Response(Integer.valueOf(exception.getCode()),exception.getMsg(),null);
        return response;
    }
}
